/**
 *  流程管理 api
 *  @module api/business
 *  @author coder
 */

// API_HOST
import {
	API_HOST
} from '@/config'

// axios
import axios from '@u/axios'

/**
 * 获取流程定义分页不分页列表
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const listFlow = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/task/flow/list'
})

/**
 * 业务办理新增数据
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const getReportList = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/fault/report/use/list'
})

/**
 * 流程定义删除
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const deleteTask = (data) => axios({
	method: 'delete',
	data: data,
	url: API_HOST + '/task/deploy/remove'
})

/**
 * 查看流程
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const getByIdFlow = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/task/flow/getById'
})

/**
 * 流程定义新增和修改
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const saveDefinition = (data) => axios({
	method: 'post',
	data: data,
	url: API_HOST + '/flow/definition/save'
})

/**
 * 流程激活和挂起
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const updateStateDefinition = (data) => axios({
	method: 'put',
	data: data,
	url: API_HOST + '/task/updateState'
})

/**
 * 获取业务办理分页分页列表
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const pageMyProcess = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/task/myProcess/page'
})

/**
 * 业务审批待审批分页
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const getTodoList = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/task/todoList'
})

/**
 * 获取流程图片
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const getReadImage = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/task/readImage'
})

/**
 * 获取流程图片
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const getReadImages = (data) => axios({
	method: 'get',
	responseType: 'arraybuffer',
	data: data,
	url: API_HOST + '/task/readImage'
})

/**
 * 业务办理提交
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const startSubmit = (data) => axios({
	method: 'post',
	data: data,
	url: API_HOST + '/task/start'
})

/**
 * 获取业务审批待审批详情单条信息详情
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const infoApproval = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/task/info'
})

/**
 * 业务办理取消
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const cancelApproval = (data) => axios({
	method: 'delete',
	data: data,
	url: API_HOST + '/task/cancel'
})

/**
 * 业务办理流程列表
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const flowRecordAction = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/task/flowRecord'
})

/**
 * 业务办理获取表单信息
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const processVariablesAction = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/flow/action/processVariables'
})

/**
 * 业务审批提交
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const completeAction = (data) => axios({
	method: 'post',
	data: data,
	url: API_HOST + '/task/complete'
})

/**
 * 业务审批已审批分页
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const getFinished = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/task/finished'
})

/**
 * 业务审批已审批详情
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const variablesTask = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/task/history/variables'
})

/**
 * 获取流程配置信息
 * @param {object} [data] 发送键值对数据
 * @returns {promise}
 */
export const getPropceeeList = (data) => axios({
	method: 'get',
	data: data,
	url: API_HOST + '/task/definition/list'
})